<template>
    <div class="">
        <div id="slider" class="mui-slider">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a class="mui-control-item mui-active" href="#item1mobile" data-wid="tab-top-subpage-1.html">
                        推荐
                    </a>
                    <a class="mui-control-item" href="#item2mobile" data-wid="tab-top-subpage-2.html">
                        热点
                    </a>
                    <a class="mui-control-item" href="#item3mobile" data-wid="tab-top-subpage-3.html">
                        北京
                    </a>
                    <a class="mui-control-item" href="#item4mobile" data-wid="tab-top-subpage-4.html">
                        推荐
                    </a>
                    <a class="mui-control-item" href="#item5mobile" data-wid="tab-top-subpage-5.html">
                        推荐
                    </a>
                    <a class="mui-control-item" href="#item6mobile" data-wid="tab-top-subpage-6.html">
                        推荐
                    </a>
                    <!-- <a :class="['mui-control-item',item.id==0?mui-active:'']" v-for="item in cates" :key="item.id" @tap="getPhotoList(item.id)">
                        {{item.title}}
                    </a> -->
                </div>
            </div>
        </div>

        <!-- 图片列表区域 -->
        <ul class="photo-list">
            <router-link v-for="item in list" :key="item.id" :to="'/home/photoInfo' + item.id" tag="li">
                <img v-lazy="item.img_url">
                <div class="info">
                    <h1 class="info-title"></h1>
                    <div class="info-body"></div>
                </div>
            </router-link>
        </ul>
    </div>
</template>
<script>
import mui from '../../lib/mui/js/mui.min.js'

export default {
    data(){
        return{
            cates:[],
            list:[]
        }
    },
    created(){
        // this.getCateNav()
        // this.getPhotoList(0)
    },
    mounted(){//当组件中的DOM结构被渲染好并放到页面中后，会执行这个钩子函数
        mui('.mui-scroll-wrapper').scroll({
            deceleration:0.0005
        })
    },
    methods: {
        getCateNav(){
            this.$http.get('api/getimgcategory').then(res=>{
                if(res.body.status == 0){
                    res.body.message.unshift({
                        title: '全部',
                        id: 0
                    })
                    this.cates = res.body.message
                }
            })
        },
        getPhotoList(cateId){
            this.$http.get('api/getimages/'+cateId).then(res=>{
                if(res.body.status==0){
                    this.list = res.body.message
                }
            })
        }
    }
}
</script>
<style lang="scss" scoped>
*{
    touch-action:pan-y;
}

.photo-list{
    list-style: none;
    padding: 0;
    margin: 10px;
    padding-bottom: 0;
    li{
        background: #CCC;
        text-align: center;
        margin-bottom: 10px;
        box-shadow: 0 0 3px #999;
        img{
            width: 100%;
            vertical-align: middle;
        }
        img[lazy=loading]{
            width: 40px;
            height: 300px;
            margin: auto;
        }
    }
}
</style>
